import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { BaseResponse } from '../base-response';
import { CaptchaService } from './captcha.service';

@Controller('captcha')
export class CaptchaController {
  constructor(private readonly captchaService: CaptchaService) {}

  @Get(':email')
  async generateCode(@Param() email: string): Promise<BaseResponse> {
    return this.captchaService.generateCode(email);
  }

  @Post()
  async checkCode(@Body() { email, code }): Promise<BaseResponse> {
    return this.captchaService.checkCode(email, code);
  }
}
